package com.supremex.aisupremex.web.controller;

import cn.hutool.core.lang.tree.Tree;
import com.supremex.aisupremex.result.Result;
import com.supremex.aisupremex.web.entity.vo.MenuVo;
import com.supremex.aisupremex.web.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author zkx
 * @since 2024-06-05
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

	@Autowired
	private MenuService menuService;



	@GetMapping("/list")
	public Result<List<MenuVo>> list() {
		List<MenuVo> menus = menuService.selectMenuList();
		return Result.success(menus);
	}

	@GetMapping("/treeselect")
	public Result<List<Tree<Long>>> treeselect() {
		List<MenuVo> menus = menuService.selectMenuList();
		List<Tree<Long>> trees = menuService.buildMenuTreeSelect(menus);
		return Result.success(trees);
	}

}
